assume cs:code
code segment
start: mov cx,3
       mov dl,9
       mov bp,0
       mov si,1
       mov bx,0b800h
       mov es,bx
    s: push cx
       mov al,dl
       out 70h,al
       in al,71h

       mov ah,al
       mov cl,4
       shr ah,cl
       and al,00001111b

       add ah,30h
       add al,30h

       mov byte ptr es:[160*12+40*2+bp],ah
       mov byte ptr es:[160*12+40*2+bp+si],2
       add bp,2
       mov byte ptr es:[160*12+40*2+bp],al
       mov byte ptr es:[160*12+40*2+bp+si],2
       add bp,2
       pop cx
       mov bx,cx
       dec cx
       jcxz ss1
       mov byte ptr es:[160*12+40*2+bp],2fh
       mov byte ptr es:[160*12+40*2+bp+si],2
       add bp,2

  ss1: dec dl
       mov cx,bx
       loop s

       mov byte ptr es:[160*12+40*2+bp],20h

       mov dl,4
       add bp,2
       mov cx,3
   s1: push cx
       mov al,dl
       out 70h,al
       in al,71h
       mov ah,al
       mov cl,4
       shr ah,cl
       and al,00001111b

       add ah,30h
       add al,30h

       mov byte ptr es:[160*12+40*2+bp],ah
       mov byte ptr es:[160*12+40*2+bp+si],2
       add bp,2
       mov byte ptr es:[160*12+40*2+bp],al
       mov byte ptr es:[160*12+40*2+bp+si],2
       add bp,2
       pop cx
       mov bx,cx
       dec cx
       jcxz ss2
       mov byte ptr es:[160*12+40*2+bp],3ah
       mov byte ptr es:[160*12+40*2+bp+si],2

  ss2: add bp,2
       sub dl,2
       mov cx,bx
       loop s1

       mov ax,4c00h
       int 21h
code ends
end start
